home *** CD-ROM | disk | FTP | other *** search
/ Champak 141 / (Vol 141) Oct 17 2011.iso / Games / gamma-bros.swf / scripts / __Packages / classes / misc / Reanimator.as < prev    next >
Encoding:
Text File  |  2011-10-17  |  4.3 KB  |  148 lines

  1. class classes.misc.Reanimator
  2. {
  3.    var x;
  4.    var y;
  5.    var xMov;
  6.    var clip;
  7.    var currentVol;
  8.    var origVol;
  9.    var xMovT = 0;
  10.    var c = 0;
  11.    var hc = 0;
  12.    var summoning = false;
  13.    var fOut = true;
  14.    var fIn = false;
  15.    var hit = false;
  16.    function Reanimator(px, py)
  17.    {
  18.       _root.rean = true;
  19.       this.x = px;
  20.       this.y = py;
  21.       this.xMov = 4;
  22.       this.xMovT = 4;
  23.       _root.d = _root.d + 1;
  24.       this.clip = _root.attachMovie("reanimator","reanimatorClip",_root.d);
  25.       this.clip._x = this.x;
  26.       this.clip._y = this.y;
  27.       this.currentVol = _root.aC1.s1.getVolume();
  28.       this.origVol = this.currentVol;
  29.    }
  30.    function main()
  31.    {
  32.       _root.c = _root.c - 1;
  33.       if(this.fOut)
  34.       {
  35.          _root.aC1.s1.setVolume(this.currentVol -= 0.25);
  36.          if(this.currentVol == 10)
  37.          {
  38.             _root.aC1.s1.setVolume(10);
  39.             this.fOut = false;
  40.          }
  41.       }
  42.       if(this.fIn)
  43.       {
  44.          _root.aC1.s1.setVolume(this.currentVol += 1);
  45.          if(this.currentVol >= this.origVol)
  46.          {
  47.             _root.aC1.s1.setVolume(this.origVol);
  48.             this.fIn = false;
  49.          }
  50.       }
  51.       if(this.clip.hitTest(_root[_root.char + "Clip"]))
  52.       {
  53.          if(_root.gems.num >= 20 && this.x > 100 && this.x < 950 && !this.hit)
  54.          {
  55.             this.hit = true;
  56.             this.summoning = true;
  57.             this.c = 0;
  58.             _root.audio.playLevel3("gem" + (random(3) + 1),_root.randRange(20,25));
  59.             this.clip.speech._visible = false;
  60.             this.clip.ship.gotoAndPlay("go");
  61.             _root.gems.addTo(-20);
  62.             this.xMovT = 0;
  63.          }
  64.          else
  65.          {
  66.             _root.gems.alpha = 120;
  67.          }
  68.       }
  69.       if(this.summoning)
  70.       {
  71.          this.c = this.c + 1;
  72.          if(this.c == 65)
  73.          {
  74.             _root.audio.playLevel2("reanimate",20);
  75.             if(_root.char == "broShip1" || _root.char == "bro1")
  76.             {
  77.                _root.bro2ShipLevel = 3;
  78.                _root.bro2ShipVar = 7;
  79.                _root.char2 = "broShip2";
  80.                _root.bro2Life = 100;
  81.                _root.broShip2 = new classes.bro.BroShip2(this.x - 100,this.y - 10);
  82.                _root.addChar("broShip2");
  83.                _root.broShip2.control = false;
  84.                _root.broShip2.reanimate();
  85.                _root.broShip2Clip.gun.gotoAndPlay("appear");
  86.             }
  87.             else
  88.             {
  89.                _root.bro1ShipLevel = 3;
  90.                _root.bro1ShipVar = 7;
  91.                _root.char2 = "broShip1";
  92.                _root.bro1Life = 100;
  93.                _root.broShip1 = new classes.bro.BroShip1(this.x - 100,this.y - 10);
  94.                _root.addChar("broShip1");
  95.                _root.broShip1.control = false;
  96.                _root.broShip1.reanimate();
  97.                _root.broShip1Clip.gun.gotoAndPlay("appear");
  98.             }
  99.          }
  100.          if(this.c == 160)
  101.          {
  102.             if(_root.char == "broShip1" || _root.char == "broShip2")
  103.             {
  104.                _root[_root.char2].action11();
  105.             }
  106.             else
  107.             {
  108.                var _loc4_ = _root.char;
  109.                _root.char = _root.char2;
  110.                _root.char2 = _loc4_;
  111.                _root[_root.char].giveControl();
  112.                _root[_root.char].weapon = _root[_root.char2].weapon;
  113.                _root.bro1Weapon = _root.bro2Weapon = _root[_root.char].weapon;
  114.                var _loc3_ = _root[_root.char].weapon;
  115.                _root[_root.char][_loc3_]();
  116.                _root[_root.char].life = 100;
  117.                _root[_root.char2].action11();
  118.             }
  119.             this.xMovT = 7;
  120.             this.fIn = true;
  121.          }
  122.       }
  123.       if(this.x > 800 && this.x < 805)
  124.       {
  125.          this.fIn = true;
  126.       }
  127.       if(this.x > 1020 && !this.fIn)
  128.       {
  129.          _root.removeFX("reanimator");
  130.       }
  131.       if(this.xMovT < this.xMov)
  132.       {
  133.          this.xMov -= 0.25;
  134.       }
  135.       else if(this.xMovT > this.xMov)
  136.       {
  137.          this.xMov += 0.25;
  138.       }
  139.       else
  140.       {
  141.          this.xMov = this.xMovT;
  142.       }
  143.       this.x += this.xMov;
  144.       this.clip.ship._y += 0.25 * Math.sin(this.hc += 0.1);
  145.       this.clip._x = this.x;
  146.    }
  147. }
  148.